package com.yc.mvc;

import com.yc.mvc.web.LoginInterceptor;
import com.yc.mvc.web.TimestampConvertor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.*;

@Configuration
@ComponentScan("com.yc.mvc")
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {

//    @Override
//    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
//        configurer.enable();
//    }

    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addConverter(new TimestampConvertor());
    }

    @Autowired
    LoginInterceptor interceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor)
                .addPathPatterns("/a.html","/a.jsp","/showme");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**")
                .addResourceLocations("file:D:\\代码\\毕设2025\\SpringMVC\\src\\main\\webapp/");
    }

}
